package com.chj.chuji.tijie02;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class StudentTet {
	public static class Student {
		public String name;
		public int id;
		public int score;

		public Student(String name, int score, int id) {
			this.name = name;
			this.id = id;
			this.score = score;
		}
	}

	public static class cmp1 implements Comparator<Student> {
		// 升序
		@Override
		public int compare(Student o1, Student o2) {
			if (o1.score != o2.score) {
				return o1.score - o2.score;
			} else {
				return o1.id - o2.id;
			}

		}

	}

	public static class cmp2 implements Comparator<Student> {
		// 降序
		@Override
		public int compare(Student o1, Student o2) {
			if (o1.score != o2.score) {
				return o2.score - o1.score;
			} else {
				return o1.id - o2.id;
			}
		}

	}

	public static void main(String[] args) {
//		Scanner sc = new Scanner(System.in);
//		while (sc.hasNext()) {
//			int n = sc.nextInt();
//			int flag = sc.nextInt();
//			List<Student> list = new ArrayList<Student>();
//			for (int i = 0; i < n; ++i) {
//				list.add(new Student(sc.next(), sc.nextInt(), i));
//			}

//		fang 90
//		yang 50
//		ning 70
		List<Student> list = new ArrayList<Student>();
		list.add(new Student("fang", 90, 1));
		list.add(new Student("yang", 50, 2));
		list.add(new Student("ning", 70, 3));
		int flag = 0;
		if (flag == 0) {
			list.sort(new cmp2());
		} else {
			list.sort(new cmp1());
		}
		for (Student s : list) {
			System.out.println(s.name + " " + s.score);
		}
//		}
	}
}
